package com.streetsmart;
/**
 * 
 * @author bhavani sudha
 *
 */
import java.util.Calendar;
import java.util.Date;
/**
 * 
 * records the event and its startTime in the computed schedule
 *
 */
public class ScheduleListItem {
	private MyEvent event;
	private Date startTime;
	
	public ScheduleListItem(MyEvent event, Date startTime){
		this.event = event;
		this.startTime = startTime;
	}
	
	/**
	 * @return the event
	 */
	public MyEvent getEvent() {
		return event;
	}

	/**
	 * @param event the event to set
	 */
	public void setEvent(MyEvent event) {
		this.event = event;
	}

	/**
	 * @return the startTime
	 */
	public Date getStartTime() {
		return startTime;
	}

	/**
	 * @param startTime the startTime to set
	 */
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	
	public String getEventName(){
		MyEvent e = getEvent();
		String name = e.getName();
		if(name.equals("StartEvent")) { name = "Start from"; }
		else if(name.equals("EndEvent")) { name = "Final Destination"; }
		return name;
	}
	
	public String getBusinessName(){
		MyEvent e = getEvent();
		String name = e.getBussName();
		return name;
	}
	
	public String getAddress(){
		return getEvent().getLocation().getAddress();
	}
	
	public String getStartingTime(){
		Calendar c= Calendar.getInstance();
		c.setTimeInMillis(getStartTime().getTime());
		int hr = c.get(Calendar.HOUR_OF_DAY);
		int min = c.get(Calendar.MINUTE);
		String tmp = "";
		if(hr / 10 < 1) tmp += "0" ;
		tmp += String.valueOf(hr);
		tmp += ":";
		if(min / 10 < 1) tmp += "0" ;
		tmp += String.valueOf(min);
		return (tmp);
	}
	
	public String getImageUrl(){
		MyEvent e = getEvent();
		return (e.getImgUrl());
	}
	
	public String getRatings(){
		String rat;
		MyEvent e = getEvent();
		if(!e.getType().equals("Must")){
			rat = String.valueOf(e.getRating());
			return rat;
		}else
		return "";
	}


	
}
